#!/usr/bin/env python
# -*- coding: UTF-8 -*-
'''
@Project ：图灵学习 
@File    ：1.使用面向对象的方式存储学生信息.py
@IDE     ：PyCharm 
@Author  ：ChenLiGao
@Date    ：2024-10-23 15:22
'''
class Student:
    stu_list = list()
    def __init__(self, stu_name, stu_age):
        self.name = stu_name
        self.age = stu_age

    def add_student(self):
        stu_info = {}
        stu_info["name"] = self.name
        stu_info["age"] = self.age
        self.stu_list.append(stu_info)

stu1 = Student("安娜", 18)
stu1.add_student()
stu2 = Student("双双", 20)
stu2.add_student()

for stu in Student.stu_list:
    print(stu)

"""
    直接对一个类的实例进行迭代循环并获取每个学员的信息
"""
for stu in stu2:
    print(stu)


